<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //test(),this指向window
        //new,this指向实例化对象
        var age = 100;
        function test() {
            this.age = 50;
            return function () {
                return this.age;
            }
        }
        //正常返回this，如果返回是引用类型，覆盖this
        var m = new test();
        //匿名函数自调用，this指向的是window
        alert(m());//100
        //普通调用，this指向的是window
        var n = test();
        alert(n());//50
    </script>
</body>

</html>